from pydantic_settings import BaseSettings
from typing import Optional

class Settings(BaseSettings):
    PROJECT_NAME: str = "ExamService"
    VERSION: str = "1.0.0"
    API_V1_STR: str = "/api/v1"
    

    MYSQL_USER: str = "mooc"
    MYSQL_PASSWORD: str = "CzHkA6JFCL5hznhP"
    MYSQL_HOST: str = "localhost"
    MYSQL_PORT: str = "3306"
    MYSQL_DATABASE: str = "mooc"
    
    SQLALCHEMY_DATABASE_URI: Optional[str] = None
    SQLALCHEMY_ECHO: bool = True

    SECRET_KEY: str = "your-secret-key-here"  
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    
    WECHAT_APPID: str = ""
    WECHAT_APPSECRET: str = ""

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.SQLALCHEMY_DATABASE_URI = (
            f"mysql+pymysql://{self.MYSQL_USER}:{self.MYSQL_PASSWORD}"
            f"@{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DATABASE}"
        )

    class Config:
        env_file = ".env"

settings = Settings()
